import 'package:flutter_test/flutter_test.dart';

import 'package:riki_router/riki_router.dart';

import 'event/demo1_package.dart';
import 'event/demo1_package1_listener.dart';
import 'event/demo1_package_listener.dart';
import 'event/demo2_package.dart';
import 'event/demo3_package.dart';

void main() {
  test('RikiEvent全流程', () {
    RikiEvent.instance.init(debug: true);

    Demo1Package demo1package = Demo1Package();
    Demo1Package demo11package = Demo1Package();
    Demo2Package demo2package = Demo2Package();
    Demo3Package demo3package = Demo3Package();

    Demo1PackageListener demo1packageListener = Demo1PackageListener();
    Demo1Package1Listener demo1package1Listener = Demo1Package1Listener();

    print('\n\n\n');

    demo1package.init();

    demo1package.addPackageListener(demo1packageListener);
    demo1package.addPackageListener(demo1package1Listener);


    print('\n\n\n');

    // 测试重复注册错误
    // demo11package.init();
    //
    // print('\n\n\n');

    demo2package.init();

    print('\n\n\n');

    demo3package.init();

    print('\n\n\n');

    RikiEvent.instance.fire(RikiEventType('test|package1'), '参数222');
    print('\n\n\n');
    // 测试不规范发送问题
    // RikiEvent.instance.fire(RikiEventType('test'), '测试不规范发送');
    RikiEvent.instance.fire(RikiEventType('test1|test1|package2'), '参数xxx');
    print('\n\n\n');
    RikiEvent.instance.fire(RikiEventType('test2|package2'), '参数xxx');

    print('\n\n\n');

    demo1package.reset();

    print('\n\n\n');

    demo2package.reset();

    print('\n\n\n');

    demo3package.reset();

    print('\n\n\n');
  });
}
